package edu.xidian.onlinedocument.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.*;
import java.io.Serializable;

@Entity
@Table(name = "op_data")
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
@NoArgsConstructor
@AllArgsConstructor
public class OperationData implements Serializable {

    @Id
    @Column(name = "op_id")
    @GeneratedValue(strategy = GenerationType.IDENTITY)
        private int opId;

    @Column(name = "doc_id")
        private int docId;

    @Column(name = "op_name")
        private String opName;

    @Column(name = "op_length")
        private int opLength;

    @Column(name = "op_value")
        private String opValue;

    @Column(name = "op_revision")
        private int opRevision;

    @JsonIgnore
    public int getOpId() {
        return this.opId;
    }

    @JsonProperty
    public void setOpId(Integer opId) {
        this.opId = opId;
    }

    public OperationData(Integer docId, Integer opRevision, String opName, Integer opLength, String opValue) {
        this.docId = docId;
        this.opRevision = opRevision;
        this.opName = opName;
        this.opLength = opLength;
        this.opValue = opValue;
    }
}
